package com.atguigu.srb.base.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author lwm1435@163.com
 * @date 2022-01-23 18:16
 * @description
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {
    /**
     * 后台管理系统接口文档
     *
     * @return
     */
    @Bean
    public Docket adminApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(new ApiInfoBuilder()
                        .title("后台管理系统接口文档")
                        .description("本文档描述了后台管理系统各个模块的接口")
                        .version("1.0")
                        .contact(new Contact("lwm", null, "lwm@163.com"))
                        .build())
                .select()
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build();
    }

    /**
     * 前台网站系统接口文档
     *
     * @return
     */
    @Bean
    public Docket webApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")
                .apiInfo(new ApiInfoBuilder()
                        .title("前台网站系统接口文档")
                        .description("本文档描述了前台网站系统各个模块的接口")
                        .version("1.0")
                        .contact(new Contact("lwm", null, "lwm@163.com"))
                        .build())
                .select()
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build();
    }
}
